<template>
	<div class="main">
		<component :is="mainComponent" v-if="isShowMainAd"></component>
		<Stock :stocks="stock"/>
		<ChannelItem :newstype="news" :newsListAd="mainNewsListAd" :newsId="news" :channelTitle="channelTitle[0]" :channelId="channelId" type="news" :channelNewsCount="channelNewsCount" />
		<div class="main_ad_item"><component :is="newsListAdComponent" v-if="isShowMainAd" id="0"></component></div>
		<ChannelItem :newstype="news" :newsListAd="mainNewsListAd" :newsId="news" :channelTitle="channelTitle[1]" :channelId="channelId" type="news" :channelNewsCount="channelNewsCount" />
		<div class="main_ad_item"><component :is="newsListAdComponent" v-if="isShowMainAd" id="1"></component></div>
		<ChannelItem :newstype="news" :newsListAd="mainNewsListAd" :newsId="news" :channelTitle="channelTitle[2]" :channelId="channelId" type="news" :channelNewsCount="channelNewsCount" />
		<div class="main_ad_item"><component :is="newsListAdComponent" v-if="isShowMainAd" id="2"></component></div>
		<ChannelItem :newstype="news" :newsListAd="mainNewsListAd" :newsId="news" :channelTitle="channelTitle[3]" :channelId="channelId" type="news" :channelNewsCount="channelNewsCount" />
		<div class="main_ad_item"><component :is="newsListAdComponent" v-if="isShowMainAd" id="3"></component></div>
		<ChannelItem :newstype="news" :newsListAd="mainNewsListAd" :newsId="news" :channelTitle="channelTitle[4]" :channelId="channelId" type="news" :channelNewsCount="channelNewsCount" />
		<MoreChannels :channels="channels" />
	</div>
</template>

<script>
	import Stock from "../components/stock/top-Stock.vue";
	import ChannelItem from "../components/common/channel-item.vue";
	import MoreChannels from "../components/common/more-channels.vue";
	export default {
		name: "Home",
		props:["type", "channels", "mainComponent", "newsListAdComponent"],
		data: function(){
			return {
				stock:["sse000001", "szse399001", "szse399006"],
				news:"0",
				channelTitle: ["新闻", "股票", "评论", "名家", "数据"],
				channelNewsCount: 10,
				channelId:"0",
				isShowMainAd: this.$store.state.ad.mainAd,
				mainNewsListAd: this.$store.state.ad.mainNewsListAd
			}
		},
		methods:{
			init:function(){
				this.$emit("upLocalData", [{
					name: "type",
					value: "home"
				},{
					name: "channelName",
					value: ""
				}]);
			}
		},
		components:{
			Stock,
			ChannelItem,
			MoreChannels
		},
		created: function(){
			this.init();
		},
		mounted:function(){
			window.scrollTo(1,1)
		},
		watch:{
			$route:function(){
				this.init();
				window.scrollTo(1,1)
			}
		}
	}
</script>

<style lang="less">
	@base:23.44/1rem;
	.main{
		min-height: 500/@base;
		.main_ad_item{
			margin:10/@base 0 0;
		}
	}
</style>
